package com.gitee.jjnnzb.designpatterninspring.business.openapi.service.impl;

import com.gitee.jjnnzb.designpatterninspring.business.openapi.entity.bo.Source1Param;
import com.gitee.jjnnzb.designpatterninspring.business.openapi.entity.bo.Source2Param;
import com.gitee.jjnnzb.designpatterninspring.business.openapi.handler.DataPushStrategy;
import com.gitee.jjnnzb.designpatterninspring.business.openapi.service.DataPushService;
import com.gitee.jjnnzb.designpatterninspring.common.enums.ChannelEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Jjn
 * @since 2023/8/10 19:44
 */
@Service
@RequiredArgsConstructor
public class DataPushServiceImpl implements DataPushService {
    
    private final DataPushStrategy dataPushStrategy;
    
    @Override
    public void handleChannel1PushedData(Source1Param source1Param) {
        Map<String, Object> map = new HashMap<>();
        map.put("params", source1Param);
        map.put("source", ChannelEnum.CHANNEL_ONE.getChannelName());
        dataPushStrategy.handle(map);
    }
    
    @Override
    public void handleChannel2PushedData(Source2Param source2Param) {
        Map<String, Object> map = new HashMap<>();
        map.put("params", source2Param);
        map.put("source", ChannelEnum.CHANNEL_TWO.getChannelName());
        dataPushStrategy.handle(map);
    }
}
